package com.ny.entity;

import lombok.Getter;
import lombok.Setter;
import org.hibernate.validator.constraints.Length;

import javax.validation.constraints.Email;
import javax.validation.constraints.NotBlank;
import java.util.Date;

@Setter
@Getter
public class User {
    private int user_id; // 自增主键

    @NotBlank(message = "用户名不能为空")
    @Length(min = 2, max = 20, message = "用户名长度需在2-20位之间")
    private String username;

    @NotBlank(message = "密码不能为空")
    @Length(min = 6, max = 20, message = "密码长度需在6-20位之间")
    private String password;

    @NotBlank(message = "昵称不能为空")
    private String nickname;

    @NotBlank(message = "手机号不能为空")
    private String phone;

    // 新增：用户邮箱（改密核心关联字段）
    @NotBlank(message = "邮箱不能为空")
    @Email(message = "邮箱格式不正确") // 校验邮箱格式
    private String email;

    private int is_active = 1; // 默认启用
    private Date created_time;

    // toString()方法补充email字段
    @Override
    public String toString() {
        return "User{" +
                "user_id=" + user_id +
                ", username='" + username + '\'' +
                ", password='" + password + '\'' +
                ", nickname='" + nickname + '\'' +
                ", phone='" + phone + '\'' +
                ", email='" + email + '\'' +
                ", is_active=" + is_active +
                ", created_time=" + created_time +
                '}';
    }
}